package search;

import java.util.Arrays;

public class Main {


    public static void main(String[] args) {

        int[] massiv = {2, 3, 4, 5, 6, 1, 7, 8, 9, 10, 11};

        int n = massiv.length;

        System.out.println("Initial array:" + Arrays.toString(massiv));
        System.out.println("Array size: " + n);

        Arrays.sort(massiv);

        System.out.println("Sorted array" + Arrays.toString(massiv));

        //System.out.println(n / 2);

        int x = massiv[0];

        System.out.println("Min:" + x);

        int end = n - 1, start = 0;
        boolean found = false;
        while (!found) {
            int i = start + (end - start) / 2;
            if (massiv[i] == x) {
                found = true;
                System.out.println("You are awesome: " + (i + 1));
            } else if (massiv[i] < x) {
                start = i;
            } else if (massiv[i] > x) {
                end = i;
            }
        }

    }
}
